﻿/**
 * Context Menu Utils Class - Created by FlashFrameLess Team 2008
 * Project - Chandon
 *
 * @author		FabioTNT / FlashFrameLessTeam - http://www.flashframeless.com/
 * @version		1.0
 */

package com.flashframeless.utils {
	
	import flash.events.ContextMenuEvent;
	import flash.ui.ContextMenuItem;
	import flash.ui.ContextMenu;
	
	//import br.com.chandon.utils.ArrMenu;
	
	public class ContextMenuUtils {
		
		private static var menu:ContextMenu = new ContextMenu();
		private static var customItems:Array = [];
		private static var separator:Boolean = false;
		
		public static function init():ContextMenu{
			menu.hideBuiltInItems();
			customItems = [];

			var credits:ContextMenuItem = new ContextMenuItem("by.grafikonstruct", true);
			credits.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onItemClickHandler);
			customItems.push(credits);
			menu.customItems = customItems;
			return menu;
		}
		
		private static function addCustomMenuItems():void {
			for ( var i:int = 0; i < ArrMenu.getArrMenu().length; i++ ) {
				addItemContextMenu( ArrMenu.getArrMenu()[i].nome );
			}
		}
		
		private static function addItemContextMenu( name:String ):void {
			var cmi:ContextMenuItem = new ContextMenuItem( name, separator );
			//cmi.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, openArea );
			separator = false;
			customItems.push( cmi );
		}
		
		private static function openArea( event:ContextMenuEvent ):void {
			trace( 'Open' );
		}
		private static function onItemClickHandler( event:ContextMenuEvent ):void {
			trace( 'HandlerClick' );
		}
		
	}
	
}